﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/site.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<%
    IList list = (IList)ViewData["list"];
%>

<div class="w_980">
	<!--back_box-->
	<div class="back_box clearfix">
    	<!--left-->
    	<% 
            Html.RenderPartial("~/Views/Shared/VipCenterList.ascx");
        %>
    	<!--right-->
        <div class="back_main">
        	<h3>自定义目录管理</h3>
            <div class="add_fav_box">
            	<div>
                <div style="height:25px;line-height:25px;">目录名:<input name="DirName" type="text" style="height:22px;width:100px;border:1px;border-color:Gray;background-color:#eeeeee;" id="DirName" /><a onclick="add();" style="height:22px;display:inline-block;margin-left:5px;"  class=" btn_reg btn_01" >保存</a></div>

                <%--<a href="#"><span>+</span>新建自定义目录</a>--%></div>
                <ul class="add_fav_ul" >
                    <%
                        foreach (Hashtable tb in list)
                        {
                            Response.Write("<li>");
                            Response.Write("<div class=\"add_fav_img\"><a href=\"#\"><img src=\"../../images/book_03.jpg\" width=\"308\" height=\"308\" /></a></div>");
                            Response.Write("<span>" + tb["dl_name"] + "</span>");
                            if (tb["dl_name"].ToString() != "我的最爱")
                            {
                                Response.Write("<a href=\"#\" onclick=\"del(" + tb["dl_id"] + ")\" class=\"fav_del_btn\"><b></b>删除</a>");
                            }
                            else
                                Response.Write("<span class=\"\" style=\"color:Red;margin-top:12px\">[默认目录]</span>");
                            Response.Write("</li>"); 
                        }
                         %>
                </ul>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    function del(id) {
        if (confirm("确定删除吗？")) {
            $.post("/Vipcenter/delDirectory.html", { id: id }, function (dta) {
                if (dta == "have") {
                    alert("删除失败，请先删除目录下的收藏记录");
                } else {
                    alert("删除目录成功");
                    window.location.reload();
                }
            });
        }
    }

    function add() {
        var name = $("#DirName").val();
        if (name == "") {
            alert("目录名不能为空"); $("#DirName").focus();return false;
        }
        $.post("/Vipcenter/checkDirectoryName.html", { name: name }, function (d) {
            if (d == "have") {
                alert("目录已存在"); $("#DirName").focus();
            } else {
                $.post("/Vipcenter/addDirectory.html", { name: name }, function (dta) {
                    alert("添加目录成功");
                    window.location.reload();
                });
            }
        });
    }
</script>
</asp:Content>
